import React, { useEffect, useState } from 'react';
import axios from 'axios';

export default function useLoadData() {
    // 数据
    const [data, setData] = useState(null);
    const [loading, setLoading] = useState(false);

    // 请求
    useEffect(async () => {
        setLoading(true);
        const res = await axios.post('/login', {
            username: 'admin',
            password: '123456',
        });
        await new Promise((resolve) => {
            setTimeout(() => {
                resolve(12312);
            }, 3000);
        });
        setLoading(false);
        setData(res.data.data);
    }, []);

    return { data, loading };
}
